import React, { useEffect, useState }  from "react";
import { find } from "../../services/class";
import List from "./List";
function Class() {
    const [classes, setClasses] = useState([]);
    const [searchParams, setSearchParams] = useState({});
    const [pagination, setPagination] = useState({
        showSizeChanger: true,
        showQuickJumper: true,
        pageSizeOptions: [5, 10, 15, 20, 25],
    });
    const show = async (params = {}) => {
        if (params.type) {
            setSearchParams(params);
        } else {
            params = { ...searchParams, ...params };
        }
        let data = await find(params);
        setClasses(data.rows);
        data.current = parseInt(data.current);
        setPagination({ ...pagination, ...data });
    };
    useEffect(() => {
        show();
    }, []);
    return (
        <div>
            <h2>班级管理</h2>
            <List show={show} classes={classes}></List>
        </div>
    );
}

export default Class;
